import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import HomeView from "@/views/blog/HomeView.vue";
import HotView from "@/views/blog/HotView.vue";
import UserInfoView from "@/views/user/UserInfoView.vue";
import UserSettingView from "@/views/user/UserSettingView.vue";
import UserView from "@/views/blog/UserView.vue";
import HomeSiderView from "@/views/sider/HomeSiderView.vue";
import HotSiderView from "@/views/sider/HotSiderView.vue";
import UserSettingSiderView from "@/views/sider/UserSettingSiderView.vue";
import { useAuthStore, useLoginUserStore } from "@/store/useLoginUserStore";
import UserSiderView from "@/views/sider/UserSiderView.vue";
import UserPasswordView from "@/views/user/UserPasswordView.vue";
import UserSettingContainer from "@/views/user/UserSettingContainer.vue";
import UserFollowListView from "@/views/user/UserFollowListView.vue";
import UserFanListView from "@/views/user/UserFanListView.vue";
import BlogSearchView from "@/views/search/BlogSearchView.vue";
import SearchView from "@/views/sider/SearchView.vue";
import UserSearchView from "@/views/search/UserSearchView.vue";
import { requireAuth } from "@/utils/authGuard";

const routes: RouteRecordRaw[] = [
  {
    path: "/",
    redirect: "/comment/1",
  },
  {
    path: "/comment/1",
    name: "home",
    component: HomeView,
    meta: {
      // requiresAuth: true,
      sider: HomeSiderView,
    },
  },
  // {
  //   path: "/hot",
  //   name: "hot",
  //   component: HotView,
  //   meta: {
  //     sider: HotSiderView,
  //   },
  // },
  // {
  //   path: "/user/:userId",
  //   name: "user",
  //   component: UserView,
  //   props: true,
  //   meta: {
  //     requiresAuth: true,
  //     activeMenu: "user",
  //     sider: UserSiderView,
  //   },
  // },
  // {
  //   path: "/user/followList",
  //   name: "userFollowList",
  //   component: UserFollowListView,
  //   meta: {
  //     requiresAuth: true,
  //     activeMenu: "user",
  //     sider: UserSiderView,
  //   },
  // },
  // {
  //   path: "/user/fanList",
  //   name: "userFanList",
  //   component: UserFanListView,
  //   meta: {
  //     requiresAuth: true,
  //     activeMenu: "user",
  //     sider: UserSiderView,
  //   },
  // },
  {
    path: "/userSetting/setting",
    name: "userSetting",
    component: UserSettingView,
    meta: {
      // requiresAuth: true,
      sider: UserSettingSiderView,
    },
  },
  // {
  //   path: "/userSetting/password",
  //   name: "userSettingPassword",
  //   component: UserPasswordView,
  //   meta: {
  //     requiresAuth: true,
  //     sider: UserSettingSiderView,
  //   },
  // },
  // {
  //   path: "/search/blog",
  //   name: "searchBlog",
  //   component: BlogSearchView,
  //   meta: {
  //     requiresAuth: true,
  //     sider: SearchView,
  //   },
  // },
  // {
  //   path: "/search/user",
  //   name: "searchUser",
  //   component: UserSearchView,
  //   meta: {
  //     requiresAuth: true,
  //     sider: SearchView,
  //   },
  // },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

router.beforeEach(requireAuth);

export default router;
